'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  // 传入加密字符串
  const verify_token = middleware.verifyToken(app.config.jwt.secret);

  router.redirect('/', '/home/index', 302);
  router.get('/home/index', controller.home.index);
  router.post('/wechat/user/login', controller.wechatuser.login);
  router.get('/wechat/user/getUserInfo', controller.wechatuser.getUserInfo);
  router.post('/wechat/user/updateUserInfo', controller.wechatuser.updateUserInfo);
  // pc端
  router.post('/user/login', controller.user.login);
  router.get('/user/info', verify_token, controller.user.info);
  router.post('/user/logout', verify_token, controller.user.logout);
  router.post('/user/list', verify_token, controller.user.list);
  router.post('/user/add', verify_token, controller.user.add);
  // router.post('/user/update', verify_token, controller.user.update);
  router.post('/user/delete', verify_token, controller.user.delete);
};
